package service

import (
	"file_sys_server/model"
	"file_sys_server/serializer"
)

type Channel1RegionService struct {
	Left1     uint   `json:"left1"`
	Right1    uint   `json:"right1"`
	Top1      uint   `json:"top1"`
	Bottom1   uint   `json:"bottom1"`
	BgFactors string `json:"bgFactors"`
}

//通道1 校准数据的增删改查

func (service *Channel1RegionService) AddRecord() serializer.Response {
	record := model.ChannelRegion_1UnionBean{
		// ID:        1,
		Left1:     service.Left1,
		Right1:    service.Right1,
		Top1:      service.Top1,
		Bottom1:   service.Bottom1,
		BgFactors: service.BgFactors,
	}

	err := model.DB.Create(&record).Error

	if err != nil {
		return serializer.Response{
			Code: 10003,
			Msg:  err.Error(),
		}
	}

	return serializer.Response{
		Code: 10000,
		Msg:  "success",
	}
}

// 获取样品列表数据
func GetChannel1Record() (*model.ChannelRegion_1UnionBean, error) {
	var channle1 *model.ChannelRegion_1UnionBean
	err := model.DB.Last(&channle1).Error

	return channle1, err
}
